﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="deliverreg.aspx.cs" Inherits="deliverreg" %>

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <title><%= SectionProxyData.GetSetValue(2) %></title>
    <link type="text/css" rel="stylesheet" href="css/common.css" />
    <link type="text/css" rel="stylesheet" href="css/page.css" />
    <link href="css/sweetalert.css" rel="stylesheet" />


    <script src="javascript/jquery.js"></script>


    <style type="text/css">

        .my_order_list li .w_txt {
            width:76%;
        }

        .my_order_list li .order-tit .time {
            width:98%;
        }

    </style>

</head>


<body>
    <div class="page">



        <div class="container">
            <form method="post" action="deliverreg.aspx" data-ajax="false">



                <ul class="my_order_list">
                    <li>
                        <div class="order-tit">
                            <span class="time"><strong>所在城市</strong>
                                <select runat="server" id="ddlcity" style="border: none;">
                                </select>

                                <span id="loaclcitybox">您在<a href="javascript:" onclick="setcity()" style="color: red;" id="mycity"></a>？</span>

                            </span>
                        </div>


                        <div class="order-tit">
                            <span class="time"><strong>手机号</strong>
                                <input name="tbmobile" type="text" id="tbmobile" class="w_txt" placeholder="请输入手机号" runat="server" />
                            </span>
                        </div>

                        <div class="order-tit" id="div_gsmCode" runat="server">
                            <span class="time"><strong>验证码</strong>
                                <input type="text" style="width: 120px;" name="tbGsmCode" id="tbGsmCode" class="w_txt" placeholder="请输入验证码" />
                                <input type="button" value="获取验证码" id="btsentcode" onclick="sentcode();" class="code_style" style="padding: 4px 2px; height:30px;" />
                            </span>
                        </div>

                        <div class="order-tit" style="border-bottom: none;">
                            <span class="time"><strong>姓名</strong>
                                <input name="tbname" type="text" id="tbname" class="w_txt" placeholder="请输入姓名" runat="server" />
                            </span>
                        </div>

                    </li>
                </ul>

                <div id="divError" runat="server" class="error_list" style="color: #FF6000; margin-left: 15px;"></div>

                <div class="view_back_con" id="div1" runat="server">
                    <input type="submit" value="下一步" class="view_back_btn" id="btsubmit" onclick="return checkuserregin()" data-ajax="false" />
                </div>
            </form>
        </div>

    </div>
</body>
</html>

<%--<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=fMnzyhYs0D1cBEl5iGMQ0Dlg"></script>--%>
 <script src="http://webapi.amap.com/maps?v=1.3&key=a67a08405e309385f32f3ef2acc8929c"></script>


<script src="javascript/jCommon.js"></script>
<script src="javascript/spin.min.js"></script>
<script src="javascript/sweetalert.min.js"></script>

<script type="text/javascript">

    //验证是否输入
    function checkuserregin() {
        var phone = document.getElementById("tbmobile").value;
        if (phone == "" || phone == null || phone == "请输入手机号") {
            alert("请输入手机号！");
            return false;
        }
        else if (!CheckPhone(phone)) {
            alert("手机号码格式错误！");
            return false;
        }
        var phone = document.getElementById("tbname").value;
        if (phone == "" || phone == null || phone == "请输入手机号") {
            alert("请输入姓名！");
            return false;
        }

        Loader.show("#btsubmit");

        return true;
    }


    //发送验证码
    var section = 60;//倒计时秒数
    function sentcode() {
        var phone = document.getElementById("tbmobile").value;
        if (phone == "" || phone == null || phone == "请输入手机号") {
            alert("请输入手机号！");
            return false;
        }
        else if (!CheckPhone(phone)) {
            alert("手机号码格式错误！");
            return false;
        }

        var input = document.getElementById('btsentcode');
        input.setAttribute('disabled', 'disabled');
        document.getElementById('btsentcode').value = '正在发送验证码';

        jQuery.ajax(
            {
                type: "post",
                url: "/Ajax/SendGmsCode.aspx",
                data: "phone=" + phone + "&fuc=deliverreg&t=" + new Date().getTime(),
                success: function (msg) {
                    switch (msg) {
                        case "0":
                            alert('服务器繁忙，请稍后再试！');
                            document.getElementById('btsentcode').value = '重新发送';
                            $("#btsentcode").removeAttr("disabled");
                            break;
                        case "1":
                            document.getElementById('btsentcode').value = '发送成功';
                            section = 60;
                            delayURL();
                            break;
                        case "-2":
                            alert('此手机号已经注册过了，请重新输入');
                            $("#btsentcode").removeAttr("disabled");
                            document.getElementById('btsentcode').value = '重新发送';
                            break;
                        case "-3":
                            alert('此手机号已经注册过了，不能获取验证码！');
                            $("#btsentcode").removeAttr("disabled");
                            document.getElementById('btsentcode').value = '重新发送';
                            break;
                    }
                }
            })
    }


    //倒计时
    function delayURL() {
        var delay = section;
        if (delay > 0) {
            delay--;
            section = delay;
            $("#btsentcode").val(delay + "秒后可重发");
        }
        else {
            $("#btsentcode").removeAttr("disabled");
            section = 0;
            document.getElementById('btsentcode').value = '重新发送';
        }
        setTimeout("delayURL()", 1000);
    }


    function CheckPhone(mobile) {
        var reg0 = /^1\d{10}$/;   //130--139。至少7位
        var my = false;
        if (reg0.test(mobile)) my = true;
        if (!my) {
            alert('对不起，您输入的手机号码错误。')
            return false;
        } else {
            return true;
        }
    }



    $(document).ready(function () {
        var err = request("msg");


        switch (err) {
            case "200":

                swal({
                    title: "温馨提示",
                    text: "注册成功，点击确定上传身份证",
                    type: "success"
                },
                        function () {
                            window.location = "uploadIDCard.aspx?id=" + request("id");
                        });
                break;

            case "201":

                swal({
                    title: "温馨提示",
                    text: "注册失败，请联系管理员",
                    type: "error"
                });
                break;


            default:
                break;
        }



    })

    function initialize() {
        Loader.show("#loaclcitybox")


        var mapObj, geolocation;
        mapObj = new AMap.Map('', {
            resizeEnable: true

        });
        //加载IP定位插件
        mapObj.plugin(["AMap.CitySearch"], function () {
            //实例化城市查询类
            var citysearch = new AMap.CitySearch();
            //自动获取用户IP，返回当前城市
            citysearch.getLocalCity();
            AMap.event.addListener(citysearch, "complete", function (result) {

                Loader.hide();
                var city = result.info;
                if (result && result.city && result.bounds) {
                    var cityinfo = result.city;
                    city = cityinfo;

                }
                $("#mycity").html(city);

            });

        });


    }

    //定位相关类
    $(function () {
        initialize();
    })

    //根据定位，选中城市
    function setcity() {
        var mycity = $.trim($("#mycity").html().replace("市",""));
        if (mycity.length == 0) {

            swal({
                title: "温馨提示",
                text: "正在定位，请稍后",
                type: "warning"
            });
        }
        else {

            var isSuccess = false;

            $("#ddlcity option").each(function () {
                if (mycity.indexOf($(this).text()) >= 0) {
                    isSuccess = true;
                    $("#ddlcity").val($(this).val());

                    return;
                }
            });

            if (!isSuccess) {
                swal({
                    title: "温馨提示",
                    text: "此城市尚未开通，你可以直接联系我们 8811000",
                    type: "warning"
                });
            }


        }
    }




</script>

  

</body>
</html>